package cn.zhz.service.provider;

import cn.zhz.dao.provider.ProviderMapper;
import cn.zhz.entity.Provider;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ProviderServiceImpl implements ProviderService{

    @Resource
    private ProviderMapper providerMapper;

    @Override
    public boolean add(Provider provider) {
        return providerMapper.add(provider) > 0;
    }

    @Override
    public List<Provider> getProviderList(String proName, String proCode, int currentPage, int pageSize) {
        List<Provider> providerList = null;
        try {
            providerList = providerMapper.getProviderList(proName,proCode,(currentPage-1) * pageSize,pageSize);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return providerList;
    }

    @Override
    public int deleteProviderById(String delId) {
        return 0;
    }

    @Override
    public Provider getProviderById(String id) {
        return providerMapper.getProviderById(id);
    }

    @Override
    public boolean modify(Provider provider) {
        return providerMapper.modify(provider) > 0;
    }

    @Override
    public int getProviderCount() {
        return providerMapper.getProviderCount();
    }

}
